package pub.wkq.springboot.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;

import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.CreditCardNumber;

@Data
public class TacoOrder implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;
    private Date createAt = new Date();
    @NotBlank(message = "deliveryName 是必填字段")
    private String deliveryName;
    @NotBlank(message = "deliveryStreet 是必填字段")
    private String deliveryStreet;
    @NotBlank(message = "deliveryCity 是必填字段")
    private String deliveryCity;
    @NotBlank(message = "deliveryState 是必填字段")
    private String deliveryState;
    @NotBlank(message = "deliveryZip 是必填字段")
    private String deliveryZip;
    @CreditCardNumber(message = "不是一个合法的信用卡号！")
    private String ccNumber;
    @Pattern(regexp = "^(0[1-9]|1[0-2])([\\/])([2-9][0-9])$", message = "必须匹配 MM/YY")
    private String ccExpiration;
    @Digits(integer = 3, fraction = 0, message = "Invalid CVV")
    private String ccCVV;

    private List<Taco> tacos = new ArrayList<>();

    public void addTaco(Taco taco) {
        this.tacos.add(taco);
    }
}